\begin{verbatim}
function Updater(force)
\end{verbatim}
\begin{verbatim}
clc

try
    unzip('http://matlab-project-smiles.googlecode.com/files/versions.zip')
catch error
    disp('Connecting to updateserver failed.')
    cont = 'no';
end
if ~(exist('cont','var') == 1)
\end{verbatim}
\begin{verbatim}
    newversion =  textread('versions.txt','%s');
    if ~(exist('force','var') == 1) % Checks whether or not to force-update
        if ~(exist('.\Core\currentversion.txt') == 2)
            if ~(exist('.\Core') == 7)
                version{1} = 'rev-2';
                force = 'install';
            else
                version{1} = 'rev00';
                force = 0;
            end
        else
            version = textread('.\Core\currentversion.txt','%s');
            force = 0;
        end
    else
        version{1} = 'rev-1'; %Forces an update
    end
    if strcmp('rev',newversion{1}(1:3)) == 1
        if (str2num(version{1}(4:5)) < str2num(newversion{1}(4:5)))
            disp('Update available.')
            updastr = sprintf(['Replace current version? ']);
            updating = upper(input(updastr, 's')); 
            %Asks whether or not to update
            switch updating
                case {'YES','Y'}
\end{verbatim}
\begin{verbatim}
                    disp Updating..
                    if ~strcmp(lower(force),'install')...
                            || (exist('.\Core\currentversion.txt') == 2)
                        delete('.\LoadSMILES.m')
                        delete('.\Updater.m')
                        rmdir('.\Core','s')
                        rmdir('.\GUI','s')
                    end
                    unzip(newversion{1}(9:length(newversion{1})))
                    version = newversion{1}(1:5);
                    fName = '.\Core\currentversion.txt';
                    fid = fopen(fName,'w');
                    if fid~=-1
                        fprintf(fid,'%s\r\n',version);
                        fclose(fid);
                    end
\end{verbatim}
\begin{verbatim}
                otherwise
                    disp('Reinitialising LoadSMILES')
            end
        else
            disp('No update available.')
        end
    else
        disp('Version file has been damaged.')
    end
    fclose('all');
    delete('versions.txt')
end
\end{verbatim}   
